<template>
  <div class="login-panel">
    <h1 class="top">爱尚收后台系统</h1>
    <el-tabs type="border-card" class="demo-tabs" stretch v-model="currentTags">
      <el-tab-pane name="account">
        <template #label>
          <el-icon style="width: 2em; height: 2em"
            ><User style="width: 1em; height: 1em; margin-right: 8px"
          /></el-icon>
          <span>账户登录</span>
        </template>
        <account ref="AccountLogin" />
      </el-tab-pane>
      <el-tab-pane name="phone" v-if="false">
        <template #label>
          <el-icon style="width: 2em; height: 2em"
            ><Iphone style="width: 1em; height: 1em; margin-right: 8px"
          /></el-icon>
          <span>手机登录</span>
        </template>
        <phone ref="PhoneLogin" />
      </el-tab-pane>
    </el-tabs>
    <div class="account-control">
      <el-checkbox v-model="isKeeppassWord">记住密码</el-checkbox>
      <el-link type="primary" v-model="isForgetpassWord">忘记密码</el-link>
    </div>
    <el-button type="primary" class="login_btn_big" @click="LoginButton"
      >立即登录</el-button
    >
  </div>
</template>

<script lang="ts">
import { defineComponent } from "vue";
import { ref } from "vue";
import type { ElForm, Instance, TabsPaneContext } from "element-plus";
import account from "./login-account.vue";
import phone from "./login-phone.vue";
const activeName = ref("first");

const handleClick = (tab: TabsPaneContext, event: Event) => {
  console.log(tab, event);
};
export default defineComponent({
  components: {
    account,
    phone
  },
  setup() {
    // 当前属性
    const isForgetpassWord = ref(false);
    const isKeeppassWord = ref(false);
    // InstanceType实例对象
    const AccountLogin = ref<InstanceType<typeof account>>();
    const PhoneLogin = ref<InstanceType<typeof phone>>();
    const currentTags = ref("account");
    // 当前方法
    const LoginButton = () => {
      if (currentTags.value === "account") {
        AccountLogin.value?.LoginAction(isKeeppassWord.value);
      } else {
        console.log("执行phone");
        // PhoneLogin.value?.
      }
    };
    return {
      isForgetpassWord,
      LoginButton,
      AccountLogin,
      isKeeppassWord,
      currentTags
    };
  }
});
</script>

<style scoped lang="less">
.demo-tabs > .el-tabs__content {
  padding: 32px;
  color: #6b778c;
  font-size: 32px;
  font-weight: 600;
}
.login-panel {
  .top {
    text-align: center;
  }
  width: 400px;
  padding: 20px;
  border: 2px solid #fff;
  border-radius: 10px;
  opacity: 0.8;
  background-color: white;
  margin: 0px 250px 0px 0px;
}
.account-control {
  display: flex;
  justify-content: space-between;
}
.login_btn_big {
  width: 100%;
  height: 40px;
}
</style>
